﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WorkStation.Frameworks.EasyBus.Pipeline.Filters
{
    /// <summary>
    /// Lambda表达式过滤器
    /// </summary>
    public class LambdaFilter : IFilter
    {
        /// <summary>
        /// 用于筛选的Lambda表达式
        /// </summary>
        public Func<object, bool> Expression;

        /// <summary>
        /// 是否匹配
        /// </summary>
        /// <param name="input">消息对象</param>
        /// <returns>true：匹配 false：不匹配</returns>
        public bool IsMatched(object input)
        {
            if (this.Expression == null)
            {
                return true;
            }
            else
            {
                return this.Expression(input);
            }
        }
    }
}
